{"cells":[{"cell_type":"code","execution_count":168,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:03.385904Z","iopub.status.busy":"2021-07-19T14:51:03.385437Z","iopub.status.idle":"2021-07-19T14:51:03.39885Z","shell.execute_reply":"2021-07-19T14:51:03.397084Z","shell.execute_reply.started":"2021-07-19T14:51:03.385811Z"},"trusted":true},"outputs":[],"source":["# import necessary Libraries\n","import numpy as np\n","import pandas as pd\n","from matplotlib import pyplot as plt"]},{"attachments":{},"cell_type":"markdown","metadata":{},"source":["movies"]},{"attachments":{},"cell_type":"markdown","metadata":{},"source":["credits"]},{"cell_type":"code","execution_count":169,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:05.238373Z","iopub.status.busy":"2021-07-19T14:51:05.23795Z","iopub.status.idle":"2021-07-19T14:51:10.154791Z","shell.execute_reply":"2021-07-19T14:51:10.15371Z","shell.execute_reply.started":"2021-07-19T14:51:05.238341Z"},"trusted":true},"outputs":[],"source":["# Read Datasets\n","credit_data=pd.read_csv(\"data/credits.csv\")"]},{"cell_type":"code","execution_count":170,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:10.156315Z","iopub.status.busy":"2021-07-19T14:51:10.155983Z","iopub.status.idle":"2021-07-19T14:51:10.170506Z","shell.execute_reply":"2021-07-19T14:51:10.169266Z","shell.execute_reply.started":"2021-07-19T14:51:10.156283Z"},"trusted":true},"outputs":[{"data":{"text/html":["<div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>cast</th>\n","      <th>crew</th>\n","      <th>id</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>[{'cast_id': 14, 'character': 'Woody (voice)', 'credit_id': '52fe4284c3...</td>\n","      <td>[{'credit_id': '52fe4284c3a36847f8024f49', 'department': 'Directing', '...</td>\n","      <td>862</td>\n","    </tr>\n","    <tr>\n","      <th>1</th>\n","      <td>[{'cast_id': 1, 'character': 'Alan Parrish', 'credit_id': '52fe44bfc3a3...</td>\n","      <td>[{'credit_id': '52fe44bfc3a36847f80a7cd1', 'department': 'Production', ...</td>\n","      <td>8844</td>\n","    </tr>\n","    <tr>\n","      <th>2</th>\n","      <td>[{'cast_id': 2, 'character': 'Max Goldman', 'credit_id': '52fe466a92514...</td>\n","      <td>[{'credit_id': '52fe466a9251416c75077a89', 'department': 'Directing', '...</td>\n","      <td>15602</td>\n","    </tr>\n","    <tr>\n","      <th>3</th>\n","      <td>[{'cast_id': 1, 'character': \"Savannah 'Vannah' Jackson\", 'credit_id': ...</td>\n","      <td>[{'credit_id': '52fe44779251416c91011acb', 'department': 'Directing', '...</td>\n","      <td>31357</td>\n","    </tr>\n","    <tr>\n","      <th>4</th>\n","      <td>[{'cast_id': 1, 'character': 'George Banks', 'credit_id': '52fe44959251...</td>\n","      <td>[{'credit_id': '52fe44959251416c75039ed7', 'department': 'Sound', 'gend...</td>\n","      <td>11862</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>"],"text/plain":["                                                                         cast  \\\n","0  [{'cast_id': 14, 'character': 'Woody (voice)', 'credit_id': '52fe4284c3...   \n","1  [{'cast_id': 1, 'character': 'Alan Parrish', 'credit_id': '52fe44bfc3a3...   \n","2  [{'cast_id': 2, 'character': 'Max Goldman', 'credit_id': '52fe466a92514...   \n","3  [{'cast_id': 1, 'character': \"Savannah 'Vannah' Jackson\", 'credit_id': ...   \n","4  [{'cast_id': 1, 'character': 'George Banks', 'credit_id': '52fe44959251...   \n","\n","                                                                         crew  \\\n","0  [{'credit_id': '52fe4284c3a36847f8024f49', 'department': 'Directing', '...   \n","1  [{'credit_id': '52fe44bfc3a36847f80a7cd1', 'department': 'Production', ...   \n","2  [{'credit_id': '52fe466a9251416c75077a89', 'department': 'Directing', '...   \n","3  [{'credit_id': '52fe44779251416c91011acb', 'department': 'Directing', '...   \n","4  [{'credit_id': '52fe44959251416c75039ed7', 'department': 'Sound', 'gend...   \n","\n","      id  \n","0    862  \n","1   8844  \n","2  15602  \n","3  31357  \n","4  11862  "]},"execution_count":170,"metadata":{},"output_type":"execute_result"}],"source":["credit_data.head()"]},{"cell_type":"code","execution_count":171,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:10.172639Z","iopub.status.busy":"2021-07-19T14:51:10.172216Z","iopub.status.idle":"2021-07-19T14:51:10.216535Z","shell.execute_reply":"2021-07-19T14:51:10.214664Z","shell.execute_reply.started":"2021-07-19T14:51:10.172595Z"},"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":["<class 'pandas.core.frame.DataFrame'>\n","RangeIndex: 45476 entries, 0 to 45475\n","Data columns (total 3 columns):\n"," #   Column  Non-Null Count  Dtype \n","---  ------  --------------  ----- \n"," 0   cast    45476 non-null  object\n"," 1   crew    45476 non-null  object\n"," 2   id      45476 non-null  int64 \n","dtypes: int64(1), object(2)\n","memory usage: 1.0+ MB\n"]}],"source":["credit_data.info()"]},{"cell_type":"code","execution_count":172,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:10.218264Z","iopub.status.busy":"2021-07-19T14:51:10.217833Z","iopub.status.idle":"2021-07-19T14:51:11.989195Z","shell.execute_reply":"2021-07-19T14:51:11.987468Z","shell.execute_reply.started":"2021-07-19T14:51:10.21822Z"},"trusted":true},"outputs":[{"name":"stderr","output_type":"stream","text":["C:\\Users\\86133\\AppData\\Local\\Temp\\ipykernel_20608\\342306074.py:2: DtypeWarning: Columns (10) have mixed types. Specify dtype option on import or set low_memory=False.\n","  meta=pd.read_csv(\"data/movies_metadata.csv\")\n"]}],"source":["# Read Meta dataset\n","meta=pd.read_csv(\"data/movies_metadata.csv\")"]},{"cell_type":"code","execution_count":173,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:11.995834Z","iopub.status.busy":"2021-07-19T14:51:11.995441Z","iopub.status.idle":"2021-07-19T14:51:12.035857Z","shell.execute_reply":"2021-07-19T14:51:12.034653Z","shell.execute_reply.started":"2021-07-19T14:51:11.995799Z"},"trusted":true},"outputs":[{"data":{"text/html":["<div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>adult</th>\n","      <th>belongs_to_collection</th>\n","      <th>budget</th>\n","      <th>genres</th>\n","      <th>homepage</th>\n","      <th>id</th>\n","      <th>imdb_id</th>\n","      <th>original_language</th>\n","      <th>original_title</th>\n","      <th>overview</th>\n","      <th>...</th>\n","      <th>release_date</th>\n","      <th>revenue</th>\n","      <th>runtime</th>\n","      <th>spoken_languages</th>\n","      <th>status</th>\n","      <th>tagline</th>\n","      <th>title</th>\n","      <th>video</th>\n","      <th>vote_average</th>\n","      <th>vote_count</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>False</td>\n","      <td>{'id': 10194, 'name': 'Toy Story Collection', 'poster_path': '/7G9915Lf...</td>\n","      <td>30000000</td>\n","      <td>[{'id': 16, 'name': 'Animation'}, {'id': 35, 'name': 'Comedy'}, {'id': ...</td>\n","      <td>http://toystory.disney.com/toy-story</td>\n","      <td>862</td>\n","      <td>tt0114709</td>\n","      <td>en</td>\n","      <td>Toy Story</td>\n","      <td>Led by Woody, Andy's toys live happily in his room until Andy's birthda...</td>\n","      <td>...</td>\n","      <td>1995-10-30</td>\n","      <td>373554033.0</td>\n","      <td>81.0</td>\n","      <td>[{'iso_639_1': 'en', 'name': 'English'}]</td>\n","      <td>Released</td>\n","      <td>NaN</td>\n","      <td>Toy Story</td>\n","      <td>False</td>\n","      <td>7.7</td>\n","      <td>5415.0</td>\n","    </tr>\n","    <tr>\n","      <th>1</th>\n","      <td>False</td>\n","      <td>NaN</td>\n","      <td>65000000</td>\n","      <td>[{'id': 12, 'name': 'Adventure'}, {'id': 14, 'name': 'Fantasy'}, {'id':...</td>\n","      <td>NaN</td>\n","      <td>8844</td>\n","      <td>tt0113497</td>\n","      <td>en</td>\n","      <td>Jumanji</td>\n","      <td>When siblings Judy and Peter discover an enchanted board game that open...</td>\n","      <td>...</td>\n","      <td>1995-12-15</td>\n","      <td>262797249.0</td>\n","      <td>104.0</td>\n","      <td>[{'iso_639_1': 'en', 'name': 'English'}, {'iso_639_1': 'fr', 'name': 'F...</td>\n","      <td>Released</td>\n","      <td>Roll the dice and unleash the excitement!</td>\n","      <td>Jumanji</td>\n","      <td>False</td>\n","      <td>6.9</td>\n","      <td>2413.0</td>\n","    </tr>\n","    <tr>\n","      <th>2</th>\n","      <td>False</td>\n","      <td>{'id': 119050, 'name': 'Grumpy Old Men Collection', 'poster_path': '/nL...</td>\n","      <td>0</td>\n","      <td>[{'id': 10749, 'name': 'Romance'}, {'id': 35, 'name': 'Comedy'}]</td>\n","      <td>NaN</td>\n","      <td>15602</td>\n","      <td>tt0113228</td>\n","      <td>en</td>\n","      <td>Grumpier Old Men</td>\n","      <td>A family wedding reignites the ancient feud between next-door neighbors...</td>\n","      <td>...</td>\n","      <td>1995-12-22</td>\n","      <td>0.0</td>\n","      <td>101.0</td>\n","      <td>[{'iso_639_1': 'en', 'name': 'English'}]</td>\n","      <td>Released</td>\n","      <td>Still Yelling. Still Fighting. Still Ready for Love.</td>\n","      <td>Grumpier Old Men</td>\n","      <td>False</td>\n","      <td>6.5</td>\n","      <td>92.0</td>\n","    </tr>\n","    <tr>\n","      <th>3</th>\n","      <td>False</td>\n","      <td>NaN</td>\n","      <td>16000000</td>\n","      <td>[{'id': 35, 'name': 'Comedy'}, {'id': 18, 'name': 'Drama'}, {'id': 1074...</td>\n","      <td>NaN</td>\n","      <td>31357</td>\n","      <td>tt0114885</td>\n","      <td>en</td>\n","      <td>Waiting to Exhale</td>\n","      <td>Cheated on, mistreated and stepped on, the women are holding their brea...</td>\n","      <td>...</td>\n","      <td>1995-12-22</td>\n","      <td>81452156.0</td>\n","      <td>127.0</td>\n","      <td>[{'iso_639_1': 'en', 'name': 'English'}]</td>\n","      <td>Released</td>\n","      <td>Friends are the people who let you be yourself... and never let you for...</td>\n","      <td>Waiting to Exhale</td>\n","      <td>False</td>\n","      <td>6.1</td>\n","      <td>34.0</td>\n","    </tr>\n","    <tr>\n","      <th>4</th>\n","      <td>False</td>\n","      <td>{'id': 96871, 'name': 'Father of the Bride Collection', 'poster_path': ...</td>\n","      <td>0</td>\n","      <td>[{'id': 35, 'name': 'Comedy'}]</td>\n","      <td>NaN</td>\n","      <td>11862</td>\n","      <td>tt0113041</td>\n","      <td>en</td>\n","      <td>Father of the Bride Part II</td>\n","      <td>Just when George Banks has recovered from his daughter's wedding, he re...</td>\n","      <td>...</td>\n","      <td>1995-02-10</td>\n","      <td>76578911.0</td>\n","      <td>106.0</td>\n","      <td>[{'iso_639_1': 'en', 'name': 'English'}]</td>\n","      <td>Released</td>\n","      <td>Just When His World Is Back To Normal... He's In For The Surprise Of Hi...</td>\n","      <td>Father of the Bride Part II</td>\n","      <td>False</td>\n","      <td>5.7</td>\n","      <td>173.0</td>\n","    </tr>\n","  </tbody>\n","</table>\n","<p>5 rows × 24 columns</p>\n","</div>"],"text/plain":["   adult  \\\n","0  False   \n","1  False   \n","2  False   \n","3  False   \n","4  False   \n","\n","                                                        belongs_to_collection  \\\n","0  {'id': 10194, 'name': 'Toy Story Collection', 'poster_path': '/7G9915Lf...   \n","1                                                                         NaN   \n","2  {'id': 119050, 'name': 'Grumpy Old Men Collection', 'poster_path': '/nL...   \n","3                                                                         NaN   \n","4  {'id': 96871, 'name': 'Father of the Bride Collection', 'poster_path': ...   \n","\n","     budget  \\\n","0  30000000   \n","1  65000000   \n","2         0   \n","3  16000000   \n","4         0   \n","\n","                                                                       genres  \\\n","0  [{'id': 16, 'name': 'Animation'}, {'id': 35, 'name': 'Comedy'}, {'id': ...   \n","1  [{'id': 12, 'name': 'Adventure'}, {'id': 14, 'name': 'Fantasy'}, {'id':...   \n","2            [{'id': 10749, 'name': 'Romance'}, {'id': 35, 'name': 'Comedy'}]   \n","3  [{'id': 35, 'name': 'Comedy'}, {'id': 18, 'name': 'Drama'}, {'id': 1074...   \n","4                                              [{'id': 35, 'name': 'Comedy'}]   \n","\n","                               homepage     id    imdb_id original_language  \\\n","0  http://toystory.disney.com/toy-story    862  tt0114709                en   \n","1                                   NaN   8844  tt0113497                en   \n","2                                   NaN  15602  tt0113228                en   \n","3                                   NaN  31357  tt0114885                en   \n","4                                   NaN  11862  tt0113041                en   \n","\n","                original_title  \\\n","0                    Toy Story   \n","1                      Jumanji   \n","2             Grumpier Old Men   \n","3            Waiting to Exhale   \n","4  Father of the Bride Part II   \n","\n","                                                                     overview  \\\n","0  Led by Woody, Andy's toys live happily in his room until Andy's birthda...   \n","1  When siblings Judy and Peter discover an enchanted board game that open...   \n","2  A family wedding reignites the ancient feud between next-door neighbors...   \n","3  Cheated on, mistreated and stepped on, the women are holding their brea...   \n","4  Just when George Banks has recovered from his daughter's wedding, he re...   \n","\n","   ... release_date      revenue runtime  \\\n","0  ...   1995-10-30  373554033.0    81.0   \n","1  ...   1995-12-15  262797249.0   104.0   \n","2  ...   1995-12-22          0.0   101.0   \n","3  ...   1995-12-22   81452156.0   127.0   \n","4  ...   1995-02-10   76578911.0   106.0   \n","\n","                                                             spoken_languages  \\\n","0                                    [{'iso_639_1': 'en', 'name': 'English'}]   \n","1  [{'iso_639_1': 'en', 'name': 'English'}, {'iso_639_1': 'fr', 'name': 'F...   \n","2                                    [{'iso_639_1': 'en', 'name': 'English'}]   \n","3                                    [{'iso_639_1': 'en', 'name': 'English'}]   \n","4                                    [{'iso_639_1': 'en', 'name': 'English'}]   \n","\n","     status  \\\n","0  Released   \n","1  Released   \n","2  Released   \n","3  Released   \n","4  Released   \n","\n","                                                                      tagline  \\\n","0                                                                         NaN   \n","1                                   Roll the dice and unleash the excitement!   \n","2                        Still Yelling. Still Fighting. Still Ready for Love.   \n","3  Friends are the people who let you be yourself... and never let you for...   \n","4  Just When His World Is Back To Normal... He's In For The Surprise Of Hi...   \n","\n","                         title  video vote_average vote_count  \n","0                    Toy Story  False          7.7     5415.0  \n","1                      Jumanji  False          6.9     2413.0  \n","2             Grumpier Old Men  False          6.5       92.0  \n","3            Waiting to Exhale  False          6.1       34.0  \n","4  Father of the Bride Part II  False          5.7      173.0  \n","\n","[5 rows x 24 columns]"]},"execution_count":173,"metadata":{},"output_type":"execute_result"}],"source":["meta.head()"]},{"cell_type":"code","execution_count":174,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:12.039213Z","iopub.status.busy":"2021-07-19T14:51:12.038873Z","iopub.status.idle":"2021-07-19T14:51:12.105427Z","shell.execute_reply":"2021-07-19T14:51:12.104427Z","shell.execute_reply.started":"2021-07-19T14:51:12.039183Z"},"trusted":true},"outputs":[{"data":{"text/plain":["1874.0       1\n","1878.0       1\n","1883.0       1\n","1887.0       1\n","1888.0       2\n","          ... \n","2015.0    1905\n","2016.0    1604\n","2017.0     532\n","2018.0       5\n","2020.0       1\n","Name: year, Length: 135, dtype: int64"]},"execution_count":174,"metadata":{},"output_type":"execute_result"}],"source":["# Extract years from \" release_date \"\n","meta[\"release_date\"]=pd.to_datetime(meta[\"release_date\"],errors=\"coerce\")\n","meta['year'] = meta['release_date'].dt.year\n","meta[\"year\"].value_counts().sort_index()"]},{"cell_type":"code","execution_count":175,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:12.107167Z","iopub.status.busy":"2021-07-19T14:51:12.106852Z","iopub.status.idle":"2021-07-19T14:51:12.148511Z","shell.execute_reply":"2021-07-19T14:51:12.147112Z","shell.execute_reply.started":"2021-07-19T14:51:12.107135Z"},"trusted":true},"outputs":[{"data":{"text/html":["<div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>genres</th>\n","      <th>id</th>\n","      <th>title</th>\n","      <th>year</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>26560</th>\n","      <td>[{'id': 12, 'name': 'Adventure'}, {'id': 28, 'name': 'Action'}, {'id': ...</td>\n","      <td>166426</td>\n","      <td>Pirates of the Caribbean: Dead Men Tell No Tales</td>\n","      <td>2017.0</td>\n","    </tr>\n","    <tr>\n","      <th>26561</th>\n","      <td>[{'id': 28, 'name': 'Action'}, {'id': 12, 'name': 'Adventure'}, {'id': ...</td>\n","      <td>141052</td>\n","      <td>Justice League</td>\n","      <td>2017.0</td>\n","    </tr>\n","    <tr>\n","      <th>26565</th>\n","      <td>[{'id': 28, 'name': 'Action'}, {'id': 12, 'name': 'Adventure'}, {'id': ...</td>\n","      <td>284053</td>\n","      <td>Thor: Ragnarok</td>\n","      <td>2017.0</td>\n","    </tr>\n","    <tr>\n","      <th>26566</th>\n","      <td>[{'id': 28, 'name': 'Action'}, {'id': 12, 'name': 'Adventure'}, {'id': ...</td>\n","      <td>283995</td>\n","      <td>Guardians of the Galaxy Vol. 2</td>\n","      <td>2017.0</td>\n","    </tr>\n","    <tr>\n","      <th>30536</th>\n","      <td>[{'id': 14, 'name': 'Fantasy'}, {'id': 28, 'name': 'Action'}, {'id': 12...</td>\n","      <td>245842</td>\n","      <td>The King's Daughter</td>\n","      <td>2017.0</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>"],"text/plain":["                                                                           genres  \\\n","26560  [{'id': 12, 'name': 'Adventure'}, {'id': 28, 'name': 'Action'}, {'id': ...   \n","26561  [{'id': 28, 'name': 'Action'}, {'id': 12, 'name': 'Adventure'}, {'id': ...   \n","26565  [{'id': 28, 'name': 'Action'}, {'id': 12, 'name': 'Adventure'}, {'id': ...   \n","26566  [{'id': 28, 'name': 'Action'}, {'id': 12, 'name': 'Adventure'}, {'id': ...   \n","30536  [{'id': 14, 'name': 'Fantasy'}, {'id': 28, 'name': 'Action'}, {'id': 12...   \n","\n","           id                                             title    year  \n","26560  166426  Pirates of the Caribbean: Dead Men Tell No Tales  2017.0  \n","26561  141052                                    Justice League  2017.0  \n","26565  284053                                    Thor: Ragnarok  2017.0  \n","26566  283995                    Guardians of the Galaxy Vol. 2  2017.0  \n","30536  245842                               The King's Daughter  2017.0  "]},"execution_count":175,"metadata":{},"output_type":"execute_result"}],"source":["# In meta dataset Extract 'genres','id','title','year' of 2017 movies\n","new_meta=meta.loc[meta.year==2017,['genres','id','title','year']]\n","new_meta.head()"]},{"cell_type":"code","execution_count":176,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:12.150591Z","iopub.status.busy":"2021-07-19T14:51:12.150136Z","iopub.status.idle":"2021-07-19T14:51:12.167062Z","shell.execute_reply":"2021-07-19T14:51:12.165892Z","shell.execute_reply.started":"2021-07-19T14:51:12.150544Z"},"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":["<class 'pandas.core.frame.DataFrame'>\n","Int64Index: 532 entries, 26560 to 45465\n","Data columns (total 4 columns):\n"," #   Column  Non-Null Count  Dtype  \n","---  ------  --------------  -----  \n"," 0   genres  532 non-null    object \n"," 1   id      532 non-null    object \n"," 2   title   532 non-null    object \n"," 3   year    532 non-null    float64\n","dtypes: float64(1), object(3)\n","memory usage: 20.8+ KB\n"]}],"source":["new_meta.info()"]},{"cell_type":"code","execution_count":177,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:12.168666Z","iopub.status.busy":"2021-07-19T14:51:12.168293Z","iopub.status.idle":"2021-07-19T14:51:12.181098Z","shell.execute_reply":"2021-07-19T14:51:12.179889Z","shell.execute_reply.started":"2021-07-19T14:51:12.168633Z"},"trusted":true},"outputs":[{"data":{"text/plain":["(532, 4)"]},"execution_count":177,"metadata":{},"output_type":"execute_result"}],"source":["new_meta.shape"]},{"cell_type":"code","execution_count":178,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:12.182887Z","iopub.status.busy":"2021-07-19T14:51:12.182469Z","iopub.status.idle":"2021-07-19T14:51:12.194124Z","shell.execute_reply":"2021-07-19T14:51:12.19248Z","shell.execute_reply.started":"2021-07-19T14:51:12.182822Z"},"trusted":true},"outputs":[],"source":["# Convert Id column datatype to int\n","new_meta[\"id\"]=new_meta[\"id\"].astype(int)\n"]},{"cell_type":"code","execution_count":179,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:12.196632Z","iopub.status.busy":"2021-07-19T14:51:12.196068Z","iopub.status.idle":"2021-07-19T14:51:12.249489Z","shell.execute_reply":"2021-07-19T14:51:12.247926Z","shell.execute_reply.started":"2021-07-19T14:51:12.19658Z"},"trusted":true},"outputs":[{"data":{"text/html":["<div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>genres</th>\n","      <th>id</th>\n","      <th>title</th>\n","      <th>year</th>\n","      <th>cast</th>\n","      <th>crew</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>[{'id': 12, 'name': 'Adventure'}, {'id': 28, 'name': 'Action'}, {'id': ...</td>\n","      <td>166426</td>\n","      <td>Pirates of the Caribbean: Dead Men Tell No Tales</td>\n","      <td>2017.0</td>\n","      <td>[{'cast_id': 1, 'character': 'Captain Jack Sparrow', 'credit_id': '52fe...</td>\n","      <td>[{'credit_id': '52fe4c9cc3a36847f8236a65', 'department': 'Production', ...</td>\n","    </tr>\n","    <tr>\n","      <th>1</th>\n","      <td>[{'id': 28, 'name': 'Action'}, {'id': 12, 'name': 'Adventure'}, {'id': ...</td>\n","      <td>141052</td>\n","      <td>Justice League</td>\n","      <td>2017.0</td>\n","      <td>[{'cast_id': 2, 'character': 'Bruce Wayne / Batman', 'credit_id': '535e...</td>\n","      <td>[{'credit_id': '55ef66dbc3a3686f1700a52d', 'department': 'Production', ...</td>\n","    </tr>\n","    <tr>\n","      <th>2</th>\n","      <td>[{'id': 28, 'name': 'Action'}, {'id': 12, 'name': 'Adventure'}, {'id': ...</td>\n","      <td>284053</td>\n","      <td>Thor: Ragnarok</td>\n","      <td>2017.0</td>\n","      <td>[{'cast_id': 0, 'character': 'Thor Odinson', 'credit_id': '545d46a80e0a...</td>\n","      <td>[{'credit_id': '56a93fa4c3a36872db001e7a', 'department': 'Writing', 'ge...</td>\n","    </tr>\n","    <tr>\n","      <th>3</th>\n","      <td>[{'id': 28, 'name': 'Action'}, {'id': 12, 'name': 'Adventure'}, {'id': ...</td>\n","      <td>283995</td>\n","      <td>Guardians of the Galaxy Vol. 2</td>\n","      <td>2017.0</td>\n","      <td>[{'cast_id': 3, 'character': 'Peter Quill / Star-Lord', 'credit_id': '5...</td>\n","      <td>[{'credit_id': '59171547925141583c0315a6', 'department': 'Sound', 'gend...</td>\n","    </tr>\n","    <tr>\n","      <th>4</th>\n","      <td>[{'id': 14, 'name': 'Fantasy'}, {'id': 28, 'name': 'Action'}, {'id': 12...</td>\n","      <td>245842</td>\n","      <td>The King's Daughter</td>\n","      <td>2017.0</td>\n","      <td>[{'cast_id': 0, 'character': 'King Louis XIV', 'credit_id': '5431dd580e...</td>\n","      <td>[{'credit_id': '5431de49c3a36825d300007e', 'department': 'Directing', '...</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>"],"text/plain":["                                                                       genres  \\\n","0  [{'id': 12, 'name': 'Adventure'}, {'id': 28, 'name': 'Action'}, {'id': ...   \n","1  [{'id': 28, 'name': 'Action'}, {'id': 12, 'name': 'Adventure'}, {'id': ...   \n","2  [{'id': 28, 'name': 'Action'}, {'id': 12, 'name': 'Adventure'}, {'id': ...   \n","3  [{'id': 28, 'name': 'Action'}, {'id': 12, 'name': 'Adventure'}, {'id': ...   \n","4  [{'id': 14, 'name': 'Fantasy'}, {'id': 28, 'name': 'Action'}, {'id': 12...   \n","\n","       id                                             title    year  \\\n","0  166426  Pirates of the Caribbean: Dead Men Tell No Tales  2017.0   \n","1  141052                                    Justice League  2017.0   \n","2  284053                                    Thor: Ragnarok  2017.0   \n","3  283995                    Guardians of the Galaxy Vol. 2  2017.0   \n","4  245842                               The King's Daughter  2017.0   \n","\n","                                                                         cast  \\\n","0  [{'cast_id': 1, 'character': 'Captain Jack Sparrow', 'credit_id': '52fe...   \n","1  [{'cast_id': 2, 'character': 'Bruce Wayne / Batman', 'credit_id': '535e...   \n","2  [{'cast_id': 0, 'character': 'Thor Odinson', 'credit_id': '545d46a80e0a...   \n","3  [{'cast_id': 3, 'character': 'Peter Quill / Star-Lord', 'credit_id': '5...   \n","4  [{'cast_id': 0, 'character': 'King Louis XIV', 'credit_id': '5431dd580e...   \n","\n","                                                                         crew  \n","0  [{'credit_id': '52fe4c9cc3a36847f8236a65', 'department': 'Production', ...  \n","1  [{'credit_id': '55ef66dbc3a3686f1700a52d', 'department': 'Production', ...  \n","2  [{'credit_id': '56a93fa4c3a36872db001e7a', 'department': 'Writing', 'ge...  \n","3  [{'credit_id': '59171547925141583c0315a6', 'department': 'Sound', 'gend...  \n","4  [{'credit_id': '5431de49c3a36825d300007e', 'department': 'Directing', '...  "]},"execution_count":179,"metadata":{},"output_type":"execute_result"}],"source":["# merge modified meta data and credit data on id column\n","data = pd.merge(new_meta, credit_data, on='id')\n","data.head()"]},{"cell_type":"code","execution_count":180,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:12.252027Z","iopub.status.busy":"2021-07-19T14:51:12.251551Z","iopub.status.idle":"2021-07-19T14:51:12.260517Z","shell.execute_reply":"2021-07-19T14:51:12.258747Z","shell.execute_reply.started":"2021-07-19T14:51:12.251989Z"},"trusted":true},"outputs":[],"source":["pd.set_option('display.max_colwidth', 75)\n"]},{"cell_type":"code","execution_count":181,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:12.262291Z","iopub.status.busy":"2021-07-19T14:51:12.261977Z","iopub.status.idle":"2021-07-19T14:51:12.273058Z","shell.execute_reply":"2021-07-19T14:51:12.272127Z","shell.execute_reply.started":"2021-07-19T14:51:12.262261Z"},"trusted":true},"outputs":[{"data":{"text/plain":["dtype('O')"]},"execution_count":181,"metadata":{},"output_type":"execute_result"}],"source":["data[\"genres\"].dtypes"]},{"cell_type":"code","execution_count":182,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:12.274613Z","iopub.status.busy":"2021-07-19T14:51:12.274322Z","iopub.status.idle":"2021-07-19T14:51:13.131329Z","shell.execute_reply":"2021-07-19T14:51:13.130284Z","shell.execute_reply.started":"2021-07-19T14:51:12.274584Z"},"trusted":true},"outputs":[],"source":["import ast\n","data[\"genres\"]=data[\"genres\"].map(lambda x : ast.literal_eval(x))\n","data[\"cast\"]=data[\"cast\"].map(lambda x : ast.literal_eval(x))\n","data[\"crew\"]=data[\"crew\"].map(lambda x : ast.literal_eval(x))"]},{"cell_type":"code","execution_count":183,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:13.133198Z","iopub.status.busy":"2021-07-19T14:51:13.132878Z","iopub.status.idle":"2021-07-19T14:51:13.140674Z","shell.execute_reply":"2021-07-19T14:51:13.139035Z","shell.execute_reply.started":"2021-07-19T14:51:13.133167Z"},"trusted":true},"outputs":[{"data":{"text/plain":["dtype('O')"]},"execution_count":183,"metadata":{},"output_type":"execute_result"}],"source":["data[\"genres\"].dtypes"]},{"cell_type":"code","execution_count":184,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:13.142723Z","iopub.status.busy":"2021-07-19T14:51:13.14237Z","iopub.status.idle":"2021-07-19T14:51:13.153629Z","shell.execute_reply":"2021-07-19T14:51:13.152696Z","shell.execute_reply.started":"2021-07-19T14:51:13.142688Z"},"trusted":true},"outputs":[],"source":["# Create a function which convert to a list of genres\n","def make_genresList(x):\n","    gen = []\n","    st = \" \"\n","    for i in x:\n","        if i.get('name') == 'Science Fiction':\n","            scifi = 'Sci-Fi'\n","            gen.append(scifi)\n","        else:\n","            gen.append(i.get('name'))\n","    if gen == []:\n","        return np.NaN\n","    else:\n","        return (st.join(gen))"]},{"cell_type":"code","execution_count":185,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:13.15555Z","iopub.status.busy":"2021-07-19T14:51:13.154954Z","iopub.status.idle":"2021-07-19T14:51:13.173998Z","shell.execute_reply":"2021-07-19T14:51:13.173145Z","shell.execute_reply.started":"2021-07-19T14:51:13.155473Z"},"trusted":true},"outputs":[{"data":{"text/plain":["0      Adventure Action Fantasy Comedy\n","1      Action Adventure Fantasy Sci-Fi\n","2      Action Adventure Fantasy Sci-Fi\n","3       Action Adventure Comedy Sci-Fi\n","4             Fantasy Action Adventure\n","                    ...               \n","526                     Romance Comedy\n","527         Crime Comedy Action Family\n","528    Family Animation Romance Comedy\n","529               Crime Drama Thriller\n","530                                NaN\n","Name: genres_list, Length: 531, dtype: object"]},"execution_count":185,"metadata":{},"output_type":"execute_result"}],"source":["data['genres_list'] = data['genres'].map(lambda x: make_genresList(x))\n","data[\"genres_list\"]"]},{"cell_type":"code","execution_count":186,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:13.175604Z","iopub.status.busy":"2021-07-19T14:51:13.175135Z","iopub.status.idle":"2021-07-19T14:51:13.186373Z","shell.execute_reply":"2021-07-19T14:51:13.185452Z","shell.execute_reply.started":"2021-07-19T14:51:13.175568Z"},"trusted":true},"outputs":[],"source":["# Create a function which extract first actor from \"cast\" column\n","def get_actor1(x):\n","    casts=[]\n","    for i in x:\n","        casts.append(i.get(\"name\"))\n","        if casts==[]:\n","            return np.Nan\n","        else:\n","            return (casts[0])"]},{"cell_type":"code","execution_count":187,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:13.187905Z","iopub.status.busy":"2021-07-19T14:51:13.187519Z","iopub.status.idle":"2021-07-19T14:51:13.206812Z","shell.execute_reply":"2021-07-19T14:51:13.205644Z","shell.execute_reply.started":"2021-07-19T14:51:13.187869Z"},"trusted":true},"outputs":[{"data":{"text/plain":["0               Johnny Depp\n","1               Ben Affleck\n","2           Chris Hemsworth\n","3               Chris Pratt\n","4            Pierce Brosnan\n","               ...         \n","526          Inka Haapamäki\n","527    Lou Diamond Phillips\n","528                    None\n","529          Sridevi Kapoor\n","530                    None\n","Name: actor_1_name, Length: 531, dtype: object"]},"execution_count":187,"metadata":{},"output_type":"execute_result"}],"source":["data['actor_1_name'] = data['cast'].map(lambda x: get_actor1(x))\n","data[\"actor_1_name\"]"]},{"cell_type":"code","execution_count":188,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:13.209198Z","iopub.status.busy":"2021-07-19T14:51:13.208568Z","iopub.status.idle":"2021-07-19T14:51:13.218031Z","shell.execute_reply":"2021-07-19T14:51:13.216885Z","shell.execute_reply.started":"2021-07-19T14:51:13.20915Z"},"trusted":true},"outputs":[],"source":["# Create a function which extract second actor from \"cast\" column\n","def get_actor2(x):\n","    casts = []\n","    for i in x:\n","        casts.append(i.get('name'))\n","    if casts == [] or len(casts)<=1:\n","        return np.NaN\n","    else:\n","        return (casts[1])"]},{"cell_type":"code","execution_count":189,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:13.220215Z","iopub.status.busy":"2021-07-19T14:51:13.219754Z","iopub.status.idle":"2021-07-19T14:51:13.239423Z","shell.execute_reply":"2021-07-19T14:51:13.237439Z","shell.execute_reply.started":"2021-07-19T14:51:13.22017Z"},"trusted":true},"outputs":[{"data":{"text/plain":["0       Javier Bardem\n","1        Henry Cavill\n","2      Tom Hiddleston\n","3         Zoe Saldana\n","4        William Hurt\n","            ...      \n","526     Rosa Honkonen\n","527     Wallace Shawn\n","528               NaN\n","529         Sajal Ali\n","530               NaN\n","Name: actor_2_name, Length: 531, dtype: object"]},"execution_count":189,"metadata":{},"output_type":"execute_result"}],"source":["data['actor_2_name'] = data['cast'].map(lambda x: get_actor2(x))\n","data[\"actor_2_name\"]"]},{"cell_type":"code","execution_count":190,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:13.241704Z","iopub.status.busy":"2021-07-19T14:51:13.241014Z","iopub.status.idle":"2021-07-19T14:51:13.249748Z","shell.execute_reply":"2021-07-19T14:51:13.248682Z","shell.execute_reply.started":"2021-07-19T14:51:13.24165Z"},"trusted":true},"outputs":[],"source":["# Create a function which extract third actor from \"cast\" column\n","def get_actor3(x):\n","    casts = []\n","    for i in x:\n","        casts.append(i.get('name'))\n","    if casts == [] or len(casts)<=2:\n","        return np.NaN\n","    else:\n","        return (casts[2])"]},{"cell_type":"code","execution_count":191,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:13.251837Z","iopub.status.busy":"2021-07-19T14:51:13.25122Z","iopub.status.idle":"2021-07-19T14:51:13.275611Z","shell.execute_reply":"2021-07-19T14:51:13.274472Z","shell.execute_reply.started":"2021-07-19T14:51:13.251768Z"},"trusted":true},"outputs":[{"data":{"text/plain":["0        Geoffrey Rush\n","1            Gal Gadot\n","2       Cate Blanchett\n","3        Dave Bautista\n","4      Benjamin Walker\n","            ...       \n","526     Tiitus Rantala\n","527        Gina Holden\n","528                NaN\n","529     Akshaye Khanna\n","530                NaN\n","Name: actor_3_name, Length: 531, dtype: object"]},"execution_count":191,"metadata":{},"output_type":"execute_result"}],"source":["data['actor_3_name'] = data['cast'].map(lambda x: get_actor3(x))\n","data[\"actor_3_name\"]"]},{"cell_type":"code","execution_count":192,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:13.277677Z","iopub.status.busy":"2021-07-19T14:51:13.27723Z","iopub.status.idle":"2021-07-19T14:51:13.288181Z","shell.execute_reply":"2021-07-19T14:51:13.286704Z","shell.execute_reply.started":"2021-07-19T14:51:13.277518Z"},"trusted":true},"outputs":[],"source":["# Create a function which extract Director name from \"crew\" column\n","def get_directors(x):\n","    dt = []\n","    st = \" \"\n","    for i in x:\n","        if i.get('job') == 'Director':\n","            dt.append(i.get('name'))\n","    if dt == []:\n","        return np.NaN\n","    else:\n","        return (st.join(dt))"]},{"cell_type":"code","execution_count":193,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:13.290102Z","iopub.status.busy":"2021-07-19T14:51:13.289715Z","iopub.status.idle":"2021-07-19T14:51:13.312375Z","shell.execute_reply":"2021-07-19T14:51:13.311207Z","shell.execute_reply.started":"2021-07-19T14:51:13.29003Z"},"trusted":true},"outputs":[{"data":{"text/plain":["0      Joachim Rønning Espen Sandberg\n","1                         Zack Snyder\n","2                       Taika Waititi\n","3                          James Gunn\n","4                       Sean McNamara\n","                    ...              \n","526                  Hannaleena Hauru\n","527             Jonathan A. Rosenbaum\n","528          Beth David Esteban Bravo\n","529                      Ravi Udyawar\n","530                     Daisy Asquith\n","Name: director_name, Length: 531, dtype: object"]},"execution_count":193,"metadata":{},"output_type":"execute_result"}],"source":["data['director_name'] = data['crew'].map(lambda x: get_directors(x))\n","data['director_name']"]},{"cell_type":"code","execution_count":194,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:13.314375Z","iopub.status.busy":"2021-07-19T14:51:13.313956Z","iopub.status.idle":"2021-07-19T14:51:13.327136Z","shell.execute_reply":"2021-07-19T14:51:13.326359Z","shell.execute_reply.started":"2021-07-19T14:51:13.314291Z"},"trusted":true},"outputs":[{"data":{"text/plain":["Index(['genres', 'id', 'title', 'year', 'cast', 'crew', 'genres_list',\n","       'actor_1_name', 'actor_2_name', 'actor_3_name', 'director_name'],\n","      dtype='object')"]},"execution_count":194,"metadata":{},"output_type":"execute_result"}],"source":["data.columns"]},{"cell_type":"code","execution_count":195,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:13.328443Z","iopub.status.busy":"2021-07-19T14:51:13.328169Z","iopub.status.idle":"2021-07-19T14:51:13.351277Z","shell.execute_reply":"2021-07-19T14:51:13.350336Z","shell.execute_reply.started":"2021-07-19T14:51:13.328416Z"},"trusted":true},"outputs":[{"data":{"text/html":["<div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>actor_1_name</th>\n","      <th>actor_2_name</th>\n","      <th>actor_3_name</th>\n","      <th>director_name</th>\n","      <th>genres_list</th>\n","      <th>title</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>Johnny Depp</td>\n","      <td>Javier Bardem</td>\n","      <td>Geoffrey Rush</td>\n","      <td>Joachim Rønning Espen Sandberg</td>\n","      <td>Adventure Action Fantasy Comedy</td>\n","      <td>Pirates of the Caribbean: Dead Men Tell No Tales</td>\n","    </tr>\n","    <tr>\n","      <th>1</th>\n","      <td>Ben Affleck</td>\n","      <td>Henry Cavill</td>\n","      <td>Gal Gadot</td>\n","      <td>Zack Snyder</td>\n","      <td>Action Adventure Fantasy Sci-Fi</td>\n","      <td>Justice League</td>\n","    </tr>\n","    <tr>\n","      <th>2</th>\n","      <td>Chris Hemsworth</td>\n","      <td>Tom Hiddleston</td>\n","      <td>Cate Blanchett</td>\n","      <td>Taika Waititi</td>\n","      <td>Action Adventure Fantasy Sci-Fi</td>\n","      <td>Thor: Ragnarok</td>\n","    </tr>\n","    <tr>\n","      <th>3</th>\n","      <td>Chris Pratt</td>\n","      <td>Zoe Saldana</td>\n","      <td>Dave Bautista</td>\n","      <td>James Gunn</td>\n","      <td>Action Adventure Comedy Sci-Fi</td>\n","      <td>Guardians of the Galaxy Vol. 2</td>\n","    </tr>\n","    <tr>\n","      <th>4</th>\n","      <td>Pierce Brosnan</td>\n","      <td>William Hurt</td>\n","      <td>Benjamin Walker</td>\n","      <td>Sean McNamara</td>\n","      <td>Fantasy Action Adventure</td>\n","      <td>The King's Daughter</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>"],"text/plain":["      actor_1_name    actor_2_name     actor_3_name  \\\n","0      Johnny Depp   Javier Bardem    Geoffrey Rush   \n","1      Ben Affleck    Henry Cavill        Gal Gadot   \n","2  Chris Hemsworth  Tom Hiddleston   Cate Blanchett   \n","3      Chris Pratt     Zoe Saldana    Dave Bautista   \n","4   Pierce Brosnan    William Hurt  Benjamin Walker   \n","\n","                    director_name                      genres_list  \\\n","0  Joachim Rønning Espen Sandberg  Adventure Action Fantasy Comedy   \n","1                     Zack Snyder  Action Adventure Fantasy Sci-Fi   \n","2                   Taika Waititi  Action Adventure Fantasy Sci-Fi   \n","3                      James Gunn   Action Adventure Comedy Sci-Fi   \n","4                   Sean McNamara         Fantasy Action Adventure   \n","\n","                                              title  \n","0  Pirates of the Caribbean: Dead Men Tell No Tales  \n","1                                    Justice League  \n","2                                    Thor: Ragnarok  \n","3                    Guardians of the Galaxy Vol. 2  \n","4                               The King's Daughter  "]},"execution_count":195,"metadata":{},"output_type":"execute_result"}],"source":["# Choose only these columns for data preprocessing\n","movies_data=data.loc[:,['actor_1_name','actor_2_name', 'actor_3_name', 'director_name',\"genres_list\",'title']]\n","movies_data.head()"]},{"cell_type":"code","execution_count":196,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:13.353393Z","iopub.status.busy":"2021-07-19T14:51:13.352792Z","iopub.status.idle":"2021-07-19T14:51:13.367339Z","shell.execute_reply":"2021-07-19T14:51:13.366194Z","shell.execute_reply.started":"2021-07-19T14:51:13.353358Z"},"trusted":true},"outputs":[{"data":{"text/plain":["actor_1_name     22\n","actor_2_name     55\n","actor_3_name     70\n","director_name     4\n","genres_list       7\n","title             0\n","dtype: int64"]},"execution_count":196,"metadata":{},"output_type":"execute_result"}],"source":["# Check null values\n","movies_data.isna().sum()"]},{"cell_type":"code","execution_count":197,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:13.369593Z","iopub.status.busy":"2021-07-19T14:51:13.369105Z","iopub.status.idle":"2021-07-19T14:51:13.387448Z","shell.execute_reply":"2021-07-19T14:51:13.386242Z","shell.execute_reply.started":"2021-07-19T14:51:13.369543Z"},"trusted":true},"outputs":[{"data":{"text/plain":["actor_1_name     0\n","actor_2_name     0\n","actor_3_name     0\n","director_name    0\n","genres_list      0\n","title            0\n","dtype: int64"]},"execution_count":197,"metadata":{},"output_type":"execute_result"}],"source":["# Drop null values\n","movies_data=movies_data.dropna(how=\"any\")\n","movies_data.isna().sum()"]},{"cell_type":"code","execution_count":198,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:13.389384Z","iopub.status.busy":"2021-07-19T14:51:13.388955Z","iopub.status.idle":"2021-07-19T14:51:13.399331Z","shell.execute_reply":"2021-07-19T14:51:13.398322Z","shell.execute_reply.started":"2021-07-19T14:51:13.389339Z"},"trusted":true},"outputs":[],"source":["# Rename columns\n","movies_data=movies_data.rename(columns={'genres_list':'genres'})\n","movies_data=movies_data.rename(columns={'title':'movie_title'})\n"]},{"cell_type":"code","execution_count":199,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:13.400962Z","iopub.status.busy":"2021-07-19T14:51:13.400502Z","iopub.status.idle":"2021-07-19T14:51:13.412422Z","shell.execute_reply":"2021-07-19T14:51:13.411425Z","shell.execute_reply.started":"2021-07-19T14:51:13.400919Z"},"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":["0                          toy story\n","1                            jumanji\n","2                   grumpier old men\n","3                  waiting to exhale\n","4        father of the bride part ii\n","                    ...             \n","45461                         subdue\n","45462            century of birthing\n","45463                       betrayal\n","45464               satan triumphant\n","45465                       queerama\n","Name: title, Length: 45466, dtype: object\n"]}],"source":["movies_data[\"movie_title\"]=movies_data[\"movie_title\"].str.lower()\n","# 使用rename()方法更改列名\n","movies_data = movies_data.rename(columns={'movie_title': 'title'})\n","meta[\"title\"]=meta[\"title\"].str.lower()\n","print(meta[\"title\"])"]},{"cell_type":"code","execution_count":200,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:13.414228Z","iopub.status.busy":"2021-07-19T14:51:13.413804Z","iopub.status.idle":"2021-07-19T14:51:13.439901Z","shell.execute_reply":"2021-07-19T14:51:13.438338Z","shell.execute_reply.started":"2021-07-19T14:51:13.414184Z"},"trusted":true},"outputs":[{"data":{"text/html":["<div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>actor_1_name</th>\n","      <th>actor_2_name</th>\n","      <th>actor_3_name</th>\n","      <th>director_name</th>\n","      <th>genres</th>\n","      <th>title</th>\n","      <th>comb</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>Johnny Depp</td>\n","      <td>Javier Bardem</td>\n","      <td>Geoffrey Rush</td>\n","      <td>Joachim Rønning Espen Sandberg</td>\n","      <td>Adventure Action Fantasy Comedy</td>\n","      <td>pirates of the caribbean: dead men tell no tales</td>\n","      <td>Johnny Depp Javier Bardem Geoffrey Rush Joachim Rønning Espen Sandberg</td>\n","    </tr>\n","    <tr>\n","      <th>1</th>\n","      <td>Ben Affleck</td>\n","      <td>Henry Cavill</td>\n","      <td>Gal Gadot</td>\n","      <td>Zack Snyder</td>\n","      <td>Action Adventure Fantasy Sci-Fi</td>\n","      <td>justice league</td>\n","      <td>Ben Affleck Henry Cavill Gal Gadot Zack Snyder</td>\n","    </tr>\n","    <tr>\n","      <th>2</th>\n","      <td>Chris Hemsworth</td>\n","      <td>Tom Hiddleston</td>\n","      <td>Cate Blanchett</td>\n","      <td>Taika Waititi</td>\n","      <td>Action Adventure Fantasy Sci-Fi</td>\n","      <td>thor: ragnarok</td>\n","      <td>Chris Hemsworth Tom Hiddleston Cate Blanchett Taika Waititi</td>\n","    </tr>\n","    <tr>\n","      <th>3</th>\n","      <td>Chris Pratt</td>\n","      <td>Zoe Saldana</td>\n","      <td>Dave Bautista</td>\n","      <td>James Gunn</td>\n","      <td>Action Adventure Comedy Sci-Fi</td>\n","      <td>guardians of the galaxy vol. 2</td>\n","      <td>Chris Pratt Zoe Saldana Dave Bautista James Gunn</td>\n","    </tr>\n","    <tr>\n","      <th>4</th>\n","      <td>Pierce Brosnan</td>\n","      <td>William Hurt</td>\n","      <td>Benjamin Walker</td>\n","      <td>Sean McNamara</td>\n","      <td>Fantasy Action Adventure</td>\n","      <td>the king's daughter</td>\n","      <td>Pierce Brosnan William Hurt Benjamin Walker Sean McNamara</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>"],"text/plain":["      actor_1_name    actor_2_name     actor_3_name  \\\n","0      Johnny Depp   Javier Bardem    Geoffrey Rush   \n","1      Ben Affleck    Henry Cavill        Gal Gadot   \n","2  Chris Hemsworth  Tom Hiddleston   Cate Blanchett   \n","3      Chris Pratt     Zoe Saldana    Dave Bautista   \n","4   Pierce Brosnan    William Hurt  Benjamin Walker   \n","\n","                    director_name                           genres  \\\n","0  Joachim Rønning Espen Sandberg  Adventure Action Fantasy Comedy   \n","1                     Zack Snyder  Action Adventure Fantasy Sci-Fi   \n","2                   Taika Waititi  Action Adventure Fantasy Sci-Fi   \n","3                      James Gunn   Action Adventure Comedy Sci-Fi   \n","4                   Sean McNamara         Fantasy Action Adventure   \n","\n","                                              title  \\\n","0  pirates of the caribbean: dead men tell no tales   \n","1                                    justice league   \n","2                                    thor: ragnarok   \n","3                    guardians of the galaxy vol. 2   \n","4                               the king's daughter   \n","\n","                                                                     comb  \n","0  Johnny Depp Javier Bardem Geoffrey Rush Joachim Rønning Espen Sandberg  \n","1                          Ben Affleck Henry Cavill Gal Gadot Zack Snyder  \n","2             Chris Hemsworth Tom Hiddleston Cate Blanchett Taika Waititi  \n","3                        Chris Pratt Zoe Saldana Dave Bautista James Gunn  \n","4               Pierce Brosnan William Hurt Benjamin Walker Sean McNamara  "]},"execution_count":200,"metadata":{},"output_type":"execute_result"}],"source":["# Make a column which is combination of all the columns of dataset\n","movies_data[\"comb\"]=movies_data[\"actor_1_name\"]+' '+movies_data[\"actor_2_name\"]+\" \"+ movies_data[\"actor_3_name\"]+' ' + movies_data[\"director_name\"]\n","movies_data.head()"]},{"cell_type":"code","execution_count":201,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:13.441636Z","iopub.status.busy":"2021-07-19T14:51:13.441341Z","iopub.status.idle":"2021-07-19T14:51:13.499251Z","shell.execute_reply":"2021-07-19T14:51:13.498064Z","shell.execute_reply.started":"2021-07-19T14:51:13.441607Z"},"trusted":true},"outputs":[{"data":{"text/html":["<div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>comb</th>\n","      <th>title</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>Johnny Depp Javier Bardem Geoffrey Rush Joachim Rønning Espen Sandberg</td>\n","      <td>pirates of the caribbean: dead men tell no tales</td>\n","    </tr>\n","    <tr>\n","      <th>1</th>\n","      <td>Ben Affleck Henry Cavill Gal Gadot Zack Snyder</td>\n","      <td>justice league</td>\n","    </tr>\n","    <tr>\n","      <th>2</th>\n","      <td>Chris Hemsworth Tom Hiddleston Cate Blanchett Taika Waititi</td>\n","      <td>thor: ragnarok</td>\n","    </tr>\n","    <tr>\n","      <th>3</th>\n","      <td>Chris Pratt Zoe Saldana Dave Bautista James Gunn</td>\n","      <td>guardians of the galaxy vol. 2</td>\n","    </tr>\n","    <tr>\n","      <th>4</th>\n","      <td>Pierce Brosnan William Hurt Benjamin Walker Sean McNamara</td>\n","      <td>the king's daughter</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>"],"text/plain":["                                                                     comb  \\\n","0  Johnny Depp Javier Bardem Geoffrey Rush Joachim Rønning Espen Sandberg   \n","1                          Ben Affleck Henry Cavill Gal Gadot Zack Snyder   \n","2             Chris Hemsworth Tom Hiddleston Cate Blanchett Taika Waititi   \n","3                        Chris Pratt Zoe Saldana Dave Bautista James Gunn   \n","4               Pierce Brosnan William Hurt Benjamin Walker Sean McNamara   \n","\n","                                              title  \n","0  pirates of the caribbean: dead men tell no tales  \n","1                                    justice league  \n","2                                    thor: ragnarok  \n","3                    guardians of the galaxy vol. 2  \n","4                               the king's daughter  "]},"execution_count":201,"metadata":{},"output_type":"execute_result"}],"source":["meta = meta[['id', 'title', 'overview','popularity','runtime','vote_average','vote_count']]\n","movies_data = movies_data[['comb','title']]\n","meta.head()\n","movies_data.head()"]},{"cell_type":"code","execution_count":202,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:13.501433Z","iopub.status.busy":"2021-07-19T14:51:13.501008Z","iopub.status.idle":"2021-07-19T14:51:13.53155Z","shell.execute_reply":"2021-07-19T14:51:13.530236Z","shell.execute_reply.started":"2021-07-19T14:51:13.501387Z"},"trusted":true},"outputs":[{"data":{"text/html":["<div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>id</th>\n","      <th>title</th>\n","      <th>overview</th>\n","      <th>popularity</th>\n","      <th>runtime</th>\n","      <th>vote_average</th>\n","      <th>vote_count</th>\n","      <th>comb</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>862</td>\n","      <td>toy story</td>\n","      <td>Led by Woody, Andy's toys live happily in his room until Andy's birthda...</td>\n","      <td>21.946943</td>\n","      <td>81.0</td>\n","      <td>7.7</td>\n","      <td>5415.0</td>\n","      <td>NaN</td>\n","    </tr>\n","    <tr>\n","      <th>1</th>\n","      <td>8844</td>\n","      <td>jumanji</td>\n","      <td>When siblings Judy and Peter discover an enchanted board game that open...</td>\n","      <td>17.015539</td>\n","      <td>104.0</td>\n","      <td>6.9</td>\n","      <td>2413.0</td>\n","      <td>NaN</td>\n","    </tr>\n","    <tr>\n","      <th>2</th>\n","      <td>15602</td>\n","      <td>grumpier old men</td>\n","      <td>A family wedding reignites the ancient feud between next-door neighbors...</td>\n","      <td>11.7129</td>\n","      <td>101.0</td>\n","      <td>6.5</td>\n","      <td>92.0</td>\n","      <td>NaN</td>\n","    </tr>\n","    <tr>\n","      <th>3</th>\n","      <td>31357</td>\n","      <td>waiting to exhale</td>\n","      <td>Cheated on, mistreated and stepped on, the women are holding their brea...</td>\n","      <td>3.859495</td>\n","      <td>127.0</td>\n","      <td>6.1</td>\n","      <td>34.0</td>\n","      <td>NaN</td>\n","    </tr>\n","    <tr>\n","      <th>4</th>\n","      <td>11862</td>\n","      <td>father of the bride part ii</td>\n","      <td>Just when George Banks has recovered from his daughter's wedding, he re...</td>\n","      <td>8.387519</td>\n","      <td>106.0</td>\n","      <td>5.7</td>\n","      <td>173.0</td>\n","      <td>NaN</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>"],"text/plain":["      id                        title  \\\n","0    862                    toy story   \n","1   8844                      jumanji   \n","2  15602             grumpier old men   \n","3  31357            waiting to exhale   \n","4  11862  father of the bride part ii   \n","\n","                                                                     overview  \\\n","0  Led by Woody, Andy's toys live happily in his room until Andy's birthda...   \n","1  When siblings Judy and Peter discover an enchanted board game that open...   \n","2  A family wedding reignites the ancient feud between next-door neighbors...   \n","3  Cheated on, mistreated and stepped on, the women are holding their brea...   \n","4  Just when George Banks has recovered from his daughter's wedding, he re...   \n","\n","  popularity  runtime  vote_average  vote_count comb  \n","0  21.946943     81.0           7.7      5415.0  NaN  \n","1  17.015539    104.0           6.9      2413.0  NaN  \n","2    11.7129    101.0           6.5        92.0  NaN  \n","3   3.859495    127.0           6.1        34.0  NaN  \n","4   8.387519    106.0           5.7       173.0  NaN  "]},"execution_count":202,"metadata":{},"output_type":"execute_result"}],"source":["movie = pd.merge(meta,movies_data,left_on='title',right_on='title',how ='left')\n","movie.head()"]},{"cell_type":"code","execution_count":203,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:13.533412Z","iopub.status.busy":"2021-07-19T14:51:13.532991Z","iopub.status.idle":"2021-07-19T14:51:13.558745Z","shell.execute_reply":"2021-07-19T14:51:13.557812Z","shell.execute_reply.started":"2021-07-19T14:51:13.533376Z"},"trusted":true},"outputs":[],"source":["# 读取keywords.csv\n","keywords = pd.read_csv('data/keywords.csv')"]},{"cell_type":"code","execution_count":204,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:13.560323Z","iopub.status.busy":"2021-07-19T14:51:13.560007Z","iopub.status.idle":"2021-07-19T14:51:13.590868Z","shell.execute_reply":"2021-07-19T14:51:13.589827Z","shell.execute_reply.started":"2021-07-19T14:51:13.560291Z"},"trusted":true},"outputs":[],"source":["# 替换NaN为''\n","keywords['keywords'] = keywords['keywords'].fillna('')\n","\n","# 定义一个函数来提取关键词的name\n","def extract_keywords(keywords_str):\n","    try:\n","        keywords_list = ast.literal_eval(keywords_str)\n","        keywords_names = ' '.join([keyword['name'] for keyword in keywords_list])\n","        return keywords_names\n","    except (ValueError, SyntaxError):\n","        return ''\n","\n","# 应用函数提取关键词的name\n","keywords['keywords_extracted'] = keywords['keywords'].apply(extract_keywords)\n","# 将标题和概述用空格隔开并存储到一个数组（列表）中\n","keywords['keywords'] = keywords['keywords_extracted']\n","# 替换NaN为''\n","keywords['keywords'] = keywords['keywords'].fillna('')"]},{"cell_type":"code","execution_count":205,"metadata":{"execution":{"iopub.execute_input":"2021-07-19T14:51:13.592465Z","iopub.status.busy":"2021-07-19T14:51:13.592168Z","iopub.status.idle":"2021-07-19T14:51:13.653329Z","shell.execute_reply":"2021-07-19T14:51:13.652329Z","shell.execute_reply.started":"2021-07-19T14:51:13.592435Z"},"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":["45432\n","45434\n"]}],"source":["# 将id列转换为整数类型，以确保合并时的一致性\n","movie['id'] = pd.to_numeric(movie['id'], errors='coerce')\n","keywords['id'] = pd.to_numeric(keywords['id'], errors='coerce')\n","# 替换NaN为''\n","movie['title'] = movie['title'].fillna('')\n","movie['overview'] = movie['overview'].fillna('')\n","# 删除无效的id行\n","# 删除重复的id，保留第一个\n","movie = movie.drop_duplicates(subset='id', keep='first')\n","# 删除重复的id，保留第一个\n","keywords = keywords.drop_duplicates(subset='id', keep='first')\n","print(len(keywords))\n","print(len(movie))"]},{"cell_type":"code","execution_count":206,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["Data has been saved to 'merged_data.csv'.\n","45434\n"]}],"source":["# 合并两个DataFrame\n","merged_data = pd.merge(movie, keywords,left_on='id',right_on='id',how ='left')\n","# 清理 NaN 值，将其替换为空字符串\n","merged_data['keywords'] = merged_data['keywords'].fillna(' ')\n","# 清理 NaN 值，将其替换为空字符串\n","merged_data['comb'] = merged_data['comb'].fillna(' ')\n","merged_data['title'] = merged_data['title'].fillna(' ')\n","merged_data['overview'] = merged_data['overview'].fillna(' ')\n","# 保存DataFrame到CSV文件，不包含行索引\n","merged_data.to_csv('data/merged_data.csv', index=False)\n","\n","print(\"Data has been saved to 'merged_data.csv'.\")\n","print(len(merged_data))"]},{"cell_type":"code","execution_count":207,"metadata":{},"outputs":[{"data":{"text/html":["<div>\n","<style scoped>\n","    .dataframe tbody tr th:only-of-type {\n","        vertical-align: middle;\n","    }\n","\n","    .dataframe tbody tr th {\n","        vertical-align: top;\n","    }\n","\n","    .dataframe thead th {\n","        text-align: right;\n","    }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n","  <thead>\n","    <tr style=\"text-align: right;\">\n","      <th></th>\n","      <th>id</th>\n","      <th>title</th>\n","      <th>overview</th>\n","      <th>popularity</th>\n","      <th>runtime</th>\n","      <th>vote_average</th>\n","      <th>vote_count</th>\n","      <th>comb</th>\n","      <th>keywords</th>\n","      <th>keywords_extracted</th>\n","    </tr>\n","  </thead>\n","  <tbody>\n","    <tr>\n","      <th>0</th>\n","      <td>862.0</td>\n","      <td>toy story</td>\n","      <td>Led by Woody, Andy's toys live happily in his room until Andy's birthda...</td>\n","      <td>21.946943</td>\n","      <td>81.0</td>\n","      <td>7.7</td>\n","      <td>5415.0</td>\n","      <td></td>\n","      <td>jealousy toy boy friendship friends rivalry boy next door new toy toy c...</td>\n","      <td>jealousy toy boy friendship friends rivalry boy next door new toy toy c...</td>\n","    </tr>\n","    <tr>\n","      <th>1</th>\n","      <td>8844.0</td>\n","      <td>jumanji</td>\n","      <td>When siblings Judy and Peter discover an enchanted board game that open...</td>\n","      <td>17.015539</td>\n","      <td>104.0</td>\n","      <td>6.9</td>\n","      <td>2413.0</td>\n","      <td></td>\n","      <td>board game disappearance based on children's book new home recluse gian...</td>\n","      <td>board game disappearance based on children's book new home recluse gian...</td>\n","    </tr>\n","    <tr>\n","      <th>2</th>\n","      <td>15602.0</td>\n","      <td>grumpier old men</td>\n","      <td>A family wedding reignites the ancient feud between next-door neighbors...</td>\n","      <td>11.7129</td>\n","      <td>101.0</td>\n","      <td>6.5</td>\n","      <td>92.0</td>\n","      <td></td>\n","      <td>fishing best friend duringcreditsstinger old men</td>\n","      <td>fishing best friend duringcreditsstinger old men</td>\n","    </tr>\n","    <tr>\n","      <th>3</th>\n","      <td>31357.0</td>\n","      <td>waiting to exhale</td>\n","      <td>Cheated on, mistreated and stepped on, the women are holding their brea...</td>\n","      <td>3.859495</td>\n","      <td>127.0</td>\n","      <td>6.1</td>\n","      <td>34.0</td>\n","      <td></td>\n","      <td>based on novel interracial relationship single mother divorce chick flick</td>\n","      <td>based on novel interracial relationship single mother divorce chick flick</td>\n","    </tr>\n","    <tr>\n","      <th>4</th>\n","      <td>11862.0</td>\n","      <td>father of the bride part ii</td>\n","      <td>Just when George Banks has recovered from his daughter's wedding, he re...</td>\n","      <td>8.387519</td>\n","      <td>106.0</td>\n","      <td>5.7</td>\n","      <td>173.0</td>\n","      <td></td>\n","      <td>baby midlife crisis confidence aging daughter mother daughter relations...</td>\n","      <td>baby midlife crisis confidence aging daughter mother daughter relations...</td>\n","    </tr>\n","  </tbody>\n","</table>\n","</div>"],"text/plain":["        id                        title  \\\n","0    862.0                    toy story   \n","1   8844.0                      jumanji   \n","2  15602.0             grumpier old men   \n","3  31357.0            waiting to exhale   \n","4  11862.0  father of the bride part ii   \n","\n","                                                                     overview  \\\n","0  Led by Woody, Andy's toys live happily in his room until Andy's birthda...   \n","1  When siblings Judy and Peter discover an enchanted board game that open...   \n","2  A family wedding reignites the ancient feud between next-door neighbors...   \n","3  Cheated on, mistreated and stepped on, the women are holding their brea...   \n","4  Just when George Banks has recovered from his daughter's wedding, he re...   \n","\n","  popularity  runtime  vote_average  vote_count comb  \\\n","0  21.946943     81.0           7.7      5415.0        \n","1  17.015539    104.0           6.9      2413.0        \n","2    11.7129    101.0           6.5        92.0        \n","3   3.859495    127.0           6.1        34.0        \n","4   8.387519    106.0           5.7       173.0        \n","\n","                                                                     keywords  \\\n","0  jealousy toy boy friendship friends rivalry boy next door new toy toy c...   \n","1  board game disappearance based on children's book new home recluse gian...   \n","2                            fishing best friend duringcreditsstinger old men   \n","3   based on novel interracial relationship single mother divorce chick flick   \n","4  baby midlife crisis confidence aging daughter mother daughter relations...   \n","\n","                                                           keywords_extracted  \n","0  jealousy toy boy friendship friends rivalry boy next door new toy toy c...  \n","1  board game disappearance based on children's book new home recluse gian...  \n","2                            fishing best friend duringcreditsstinger old men  \n","3   based on novel interracial relationship single mother divorce chick flick  \n","4  baby midlife crisis confidence aging daughter mother daughter relations...  "]},"execution_count":207,"metadata":{},"output_type":"execute_result"}],"source":["merged_data.head()"]},{"cell_type":"code","execution_count":208,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["        id                        title  \\\n","0    862.0                    toy story   \n","1   8844.0                      jumanji   \n","2  15602.0             grumpier old men   \n","3  31357.0            waiting to exhale   \n","4  11862.0  father of the bride part ii   \n","\n","                                                                     overview  \\\n","0  Led by Woody, Andy's toys live happily in his room until Andy's birthda...   \n","1  When siblings Judy and Peter discover an enchanted board game that open...   \n","2  A family wedding reignites the ancient feud between next-door neighbors...   \n","3  Cheated on, mistreated and stepped on, the women are holding their brea...   \n","4  Just when George Banks has recovered from his daughter's wedding, he re...   \n","\n","  popularity  runtime  vote_average  vote_count comb  \\\n","0  21.946943     81.0           7.7      5415.0        \n","1  17.015539    104.0           6.9      2413.0        \n","2    11.7129    101.0           6.5        92.0        \n","3   3.859495    127.0           6.1        34.0        \n","4   8.387519    106.0           5.7       173.0        \n","\n","                                                                     keywords  \\\n","0  jealousy toy boy friendship friends rivalry boy next door new toy toy c...   \n","1  board game disappearance based on children's book new home recluse gian...   \n","2                            fishing best friend duringcreditsstinger old men   \n","3   based on novel interracial relationship single mother divorce chick flick   \n","4  baby midlife crisis confidence aging daughter mother daughter relations...   \n","\n","                                                           keywords_extracted  \\\n","0  jealousy toy boy friendship friends rivalry boy next door new toy toy c...   \n","1  board game disappearance based on children's book new home recluse gian...   \n","2                            fishing best friend duringcreditsstinger old men   \n","3   based on novel interracial relationship single mother divorce chick flick   \n","4  baby midlife crisis confidence aging daughter mother daughter relations...   \n","\n","    ad  \n","0  1.0  \n","1  1.0  \n","2  1.0  \n","3  1.0  \n","4  1.0  \n"]}],"source":["# 添加新列 'ad' 并将其值设置为 0\n","merged_data['ad'] = 1.0\n","\n","# 显示添加新列后的数据\n","print(merged_data.head())"]},{"cell_type":"code","execution_count":209,"metadata":{},"outputs":[],"source":["merged_data.to_csv(\"updata/merge_data.csv\")"]}],"metadata":{"kaggle":{"accelerator":"tpuV38","dataSources":[{"datasetId":3405,"sourceId":6663,"sourceType":"datasetVersion"},{"datasetId":7181,"sourceId":10279,"sourceType":"datasetVersion"},{"datasetId":1469427,"sourceId":2428269,"sourceType":"datasetVersion"}],"dockerImageVersionId":30120,"isGpuEnabled":false,"isInternetEnabled":false,"language":"python","sourceType":"notebook"},"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.8.17"}},"nbformat":4,"nbformat_minor":4}
